import httpReuqest from '@/assets/httpsRequest';

export default {
  namespaced: true,
  state: {
    newsDetail: {},
  },
  actions: {
    async getNewsDetail({ commit }, { payload }) {
      const res = await httpReuqest({
        url: `getnew/${payload.newsId}`,
      });
      const { status, data = {} } = res;
      const { message = [] } = data;
      if (status === 200) {
        commit({
          type: 'setNewsDetail',
          payload: {
            newsDetail: message[0] || {},
          },
        });
      }
    },
  },
  mutations: {
    setNewsDetail(state, { payload }) {
      Object.assign(state, payload);
    },
  },
};
